package com.gourd.notice.controller;

import com.github.jackieonway.sms.entity.AliSmsRequest;
import com.github.jackieonway.sms.entity.TencentSmsRequest;
import com.github.jackieonway.sms.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gourd
 */
@RestController
@RequestMapping("/sms")
@Api(tags = "sms", description = "sms控制器")
public class SmsController {

    @Qualifier("tencentSmsService")
    private SmsService tencentSmsService;

    @Qualifier("aliSmsService")
    private SmsService aliSmsService;

    @GetMapping("/tencent")
    @ApiOperation(value="tencent短信发送")
    public Object tencent() {
        // 具体配置请参照具体运营商
        String[] param = {"5678", "5"};
        TencentSmsRequest tencentSmsRequest = new TencentSmsRequest();
        tencentSmsRequest.setPhoneNumber(new String[]{"13584278267"});
        tencentSmsRequest.setParams(param);
        return tencentSmsService.sendTemplateSms("328921", tencentSmsRequest);
    }

    @GetMapping("/ali")
    @ApiOperation(value="ali短信发送")
    public Object ali() {
        // 具体配置请参照具体运营商
        AliSmsRequest aliSmsRequest = new AliSmsRequest();
        aliSmsRequest.setOutId("420");
        aliSmsRequest.setPhoneNumbers(new String[]{"13584278267"});
        aliSmsRequest.setTemplateParam("{\"code\":\"asdsads\"}");
        aliSmsRequest.setSignName("123");
        return aliSmsService.sendTemplateSms("328921", aliSmsRequest);
    }

}